package com.example.back.controller.otd;

import com.example.back.entity.otd.Videos;
import com.example.back.mapper.otd.VideoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
public class VideoController {
    @Autowired
    private VideoMapper videoMapper;
    @GetMapping("/video")
    public ArrayList<Videos> queryVideo()
    {
      return videoMapper.getVideos();
    }

    @PostMapping("/video")
    public int insertVideo(@RequestBody Videos videos)
    {
      return videoMapper.insertVideo(videos);
    }

    @GetMapping("/video/userId/{userId}")
    public ArrayList<Videos> queryVideoByUserId(@PathVariable("userId") String  userId)
    {
      return videoMapper.queryVideoByUserId(userId);
    }
    @GetMapping("/video/viewnum")
    public ArrayList<Videos> queryVideoByviewnum()
    {
      return videoMapper.queryVideoByviewnum();
    }
    @PutMapping("/video/viewnum/{id}")
    public int updateVideoviewnum(@PathVariable("id") String id ){
        return videoMapper.updateVideoviewnum(id);
    }
}
